package com.fr.report.script.function;

import com.fr.base.core.DateUtils;
import com.fr.report.script.Function;
import com.fr.report.script.Function.Type;
import com.fr.report.script.NormalFunction;
import com.fr.report.script.Primitive;
import java.util.Date;

public class DATESUBDATE extends NormalFunction
{
  public Object run(Object[] paramArrayOfObject)
  {
    if (paramArrayOfObject.length != 3)
      return Primitive.ERROR_NAME;
    Object localObject1 = paramArrayOfObject[0];
    Object localObject2 = paramArrayOfObject[1];
    Object localObject3 = paramArrayOfObject[2];
    Date localDate1 = DateUtils.object2Date(localObject1, false);
    Date localDate2 = DateUtils.object2Date(localObject2, false);
    String str = null;
    if (localObject3 instanceof String)
      str = (String)localObject3;
    else
      return Primitive.ERROR_NAME;
    return new Long(DateUtils.subtractDate(localDate1, localDate2, str));
  }

  public Function.Type getType()
  {
    return Function.DATETIME;
  }

  public String getCN()
  {
    return "DATESUBDATE(date1, date2, op):返回两个日期之间的时间差。\nop表示返回的时间单位：\n\"s\"，以秒为单位。\n\"m\"，以分钟为单位。\n\"h\"，以小时为单位。\n\"d\"，以天为单位。\n\"w\"，以周为单位。\n示例：\nDATESUBDATE(\"2008-08-08\", \"2008-06-06\",\"h\")等于1512。";
  }

  public String getEN()
  {
    return "";
  }
}